<?php
/**
 * @Author: xuzhiyi
 * @Date:   2016-02-16 20:57:19
 * @Last Modified by:   xuzhiyi
 * @Last Modified time: 2016-02-27 11:49:32
 * ------------------------------------------------ *
 * 商品分类                                          *
 * ------------------------------------------------ */

namespace Admin\Controller;
class GoodsCatsController extends CommonController {
	public function index(){
		if(IS_AJAX){
 			switch(I('ajax')){
 				case "catFlag":
					$status = D('GoodsCats')->editStatus();
					$this->ajaxReturn($status);
					break;
				case "catSort":
					//$this->ajaxReturn(I('data'));
					$status = D('GoodsCats')->editSort();
					$this->ajaxReturn($status);
					break;
				case "delGoodsCats":
					$status = D('GoodsCats')->delGoodsCats();
					$this->ajaxReturn($status);
					break;

				case "addGoodsCats":
					$status = D('GoodsCats')->addGoodsCats();
					if($status){
						$this->success('分类添加成功！','',true);	
					}
					$this->error('分类添加失败！','',true);
					break;
				case "editGoodsCats":
					$status = D('GoodsCats')->editGoodsCats();
					if($status){
						$this->success('分类修改成功！','',true);	
					}
					$this->error('分类修改失败！','',true);
					break;
				default:
					$rs=D('GoodsCats')->getGoodsCats();
					$this->ajaxReturn(getTree($rs));
			}
		}

		$parentNames= D('GoodsCats')->getGoodsCats();		
		$this->assign('parentNames',$parentNames);
		$this->display();
	}
}